package org.itrip.dao.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.itrip.config.SpringMongoConfig;
import org.itrip.dao.BaseDAO;
import org.itrip.entity.WebSite;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by 涛 on 2016/3/17.
 */
@Repository
public class WebSiteDAO implements BaseDAO<WebSite>{

    private static Log log = LogFactory.getLog(WebSiteDAO.class.getName());
    private static ApplicationContext ctx;
    private static MongoOperations mongoOperation;

    static {
        ctx = new AnnotationConfigApplicationContext(SpringMongoConfig.class);
        mongoOperation = (MongoOperations) ctx.getBean("mongoTemplate");
    }


    @Override
    public void insert(WebSite webSite) {

    }

    @Override
    public WebSite queryOne(String id) {
        return null;
    }

    @Override
    public List<WebSite> queryAll() {
        return mongoOperation.findAll(WebSite.class);
    }

    @Override
    public List<WebSite> queryByRegex(String regex) {
        return null;
    }

    @Override
    public void removeOne(String id) {

    }

    @Override
    public void removeAll() {

    }

    @Override
    public void queryAndModify(String id) {

    }
}
